//
// Created by 夏申频 on 17/1/26.
//

#ifndef JJPEG_NATIVE_IMAGECODEC_H
#define JJPEG_NATIVE_IMAGECODEC_H

#if defined(_WIN32)
#ifdef IMAGE_CODEC_EXPORTS
#define IMAGE_CODEC_IMEXPORT(returntype) __declspec(dllexport) returntype __stdcall
#else
#define IMAGE_CODEC_IMEXPORT(returntype) __declspec(dllimport) returntype __stdcall
#endif
#else
#if __GNUC__ >= 4
#define IMAGE_CODEC_IMEXPORT(returntype) __attribute__ ((visibility ("default"))) returntype
#else
#define IMAGE_CODEC_IMEXPORT(returntype) returntype
#endif
#endif /* _WIN32 */

#ifdef __cplusplus
extern "C"{
#endif

typedef struct {
    int width;
    int height;
    int channels;
    int bitsPerSample;
    int colorSpace;
} ImageMeta;

typedef struct {
    const char* input;
    char** output;
    long inputSize;
    long* outputSize;
    int extra[4];
    ImageMeta* meta;
}ImageCodecContext;

#define LOSSLESS 0
#define QUALITY 1

typedef enum{
    CJPEG8 = 0,CJPEG12 = 1,CJPEG16 = 2,CJPLS =3
} Codec;

typedef struct{
    int code;
    char msg[256];
} ImageCodecErr;

IMAGE_CODEC_IMEXPORT(int) decode(Codec c,ImageCodecContext* codecContext,ImageCodecErr* err);
IMAGE_CODEC_IMEXPORT(int) encode(Codec c,ImageCodecContext* codecContext,ImageCodecErr* err);

IMAGE_CODEC_IMEXPORT(void) freeContextOutput(ImageCodecContext* codecContext);

#ifdef __cplusplus
};
#endif

#endif //JJPEG_NATIVE_IMAGECODEC_H
